import instance, { get, post } from '@/utils/request'
import { AxiosPromise } from 'axios'
import { MenuQuery, MenuVO, MenuForm } from './types'

/**
 * 获取路由列表
 */
export function listRoutes<T = any, U = any>(params = {} as U, options = {}) {
	return get<T, U>('/apifox/menus/routes', params, options)
}

/**
 * 获取菜单树形列表
 *
 * @param queryParams
 */
export function listMenus<T = any, U = any>(params = {} as U, options = {}) {
	// return get<MenuQuery, MenuVO[]>('/api/v1/menus', params)
	return get<T, U>('/apifox/menus/routes', params, options)
}

/**
 * 获取菜单下拉树形列表
 */
export function getMenuOptions<T = any, U = any>(params, options) {
	return get<T, U>('/api/v1/menus/options', params, options)
}

/**
 * 获取菜单表单数据
 *
 * @param id
 */
export function getMenuForm(id: number): AxiosPromise<MenuForm> {
	return get('/api/v1/menus/' + id + '/form')
}

/**
 * 添加菜单
 *
 * @param data
 */
export function addMenu(params: MenuForm) {
	return post('/api/v1/menus/menus', params)
}

/**
 * 修改菜单
 *
 * @param id
 * @param data
 */
export function updateMenu(id: string, data: MenuForm) {
	// return request({
	// 	url: '/api/v1/menus/' + id,
	// 	method: 'put',
	// 	data: data,
	// })
}

/**
 * 删除菜单
 *
 * @param id 菜单ID
 */
export function deleteMenu(id: number) {
	// return request({
	// 	url: '/api/v1/menus/' + id,
	// 	method: 'delete',
	// })
}
